/**
 * use to create common model at initialize stage
 * client side
 * argument: 
 */
(function($,undefined){
	$.widget('yi.commonModel',{
		var ui,
		options:{
			mode:'create'
		},
		_create: function(){
			var self = this;
			options = self.options;
			var root = $('data-root').val();//get root path for imgs
			ui = $('<div id="modelEditPanel" class="modal hide fade" style="display:none"></div>');
			var uiStr = '<div class="modal-header"><button type="button" class="close" data-dismiss="modal">';
			uiStr += '<img src="' + root +'/yi/imgs/fancy_close.png" /></button><h3>Model Setting</h3></div>';
			uiStr += '<div class="modal-body"></div>';
			uiStr += '<div class="modal-footer">';
			uiStr += '<a href="#" class="btn" data-dismiss="modal">Close</a>';
			uiStr += '<a href="#"  id="saveBtn" class="btn btn-primary">Save changes</a></div>';
			
			$(parent).append(ui);
			ui.append(uiStr);
			//construct params
//			if(options.mode == 'create'){
				//pass th as arr
				var html = '<ul>';
				$.each(options.models,function(index,ele){
					html += '<row>';
					html += '<li class="span4">' + ele.name + "</li>";					
					html += '<li class="span8">' + getHtmlByFieldType(ele) + "</li>";
					html += '</row>';
					html += '<row><li class="span12 separator"></li></row>';
				});
				html += '';
				html += '</ul>'
//			}else if(options.mode == 'edit'){
//				//pass tr
//			}
			$(parent).modal();
		},
		destroy: function(){
			$(parent).modal(hide);
			$(parent).remove(ui);
		}
	});
}(jQuery));